package com.cloud.jdkTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class ArrayListTest {
    public static void main(String[] args) {
        Object[] elementData = new Object[]{"shuchuanbiao", new Object(), 89l};
        Object[] newElementData = Arrays.copyOf(elementData, elementData.length, Object[].class);
        for (int i = 0; i < newElementData.length; ++i) {
            System.out.println(newElementData[i]);
        }
        System.out.println(elementData[1] == newElementData[1]);
        List<String> list = new ArrayList<String>(10);
        System.out.println(list.size());
        for (int i = 0; i < 10; ++i) {
            list.set(i, i + "");
        }
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        try {
            list.set(10, "10");
        } catch (IndexOutOfBoundsException e) {
            System.out.println("I have catch the IndexOutOfBoundsException: " + e);
        } finally {
            System.out.println("the program has finished");
        }

    }
}
